package jk.zmn.sorm.core;

/**
 * @author 张梦楠
 * @简书：https://www.jianshu.com/u/d611be10d1a6
 * @码云：https://gitee.com/zhangqiye/events
 * @Date: 2018/6/15
 *
 *  负责根据配置文件，管理query对象
 *
 **/
public class QueryFactory {

    private static QueryFactory queryFactory = new QueryFactory();

    private static Class c;

    static {
        if (DBManager.getConfiguration().getUseDB().equalsIgnoreCase("mysql")){

            try {
                c = Class.forName("jk.zmn.sorm.core.MySqlQuery");
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        }


        //将对应的类和表封装起来
        TableContext.loadTablePoToMap();
    }
    /*
     构造器私有化
     */
    private QueryFactory(){
    }

    public static Query createQuery(){
        try {
            return (Query) c.newInstance();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }




}
